﻿using System;
using System.Collections.Generic;

namespace AppMain
{
    public class Box2D
    {
        //size
        public float sizeX;
        public float sizeZ;
        //pos
        public float posX;
        public float posZ;
        //offset
        public float offsetX = 0;
        public float offsetZ = 0;


        public Box2D()
        {

        }

        public Box2D(float sizeX, float sizeZ, float posX, float posZ, float offsetX, float offsetZ)
        {
            this.sizeX = sizeX;

            this.sizeZ = sizeZ;

            this.posX = posX;

            this.posZ = posZ;

            this.offsetX = offsetX;

            this.offsetZ = offsetZ;
        }

        public Box2D(float[] sizeLst, float[] offsetLst, float posX, float posZ)
        {
            this.sizeX = sizeLst[0];

            this.sizeZ = sizeLst[1];

            this.posX = posX;

            this.posZ = posZ;

            this.offsetX = offsetLst[0];

            this.offsetZ = offsetLst[1];
        }

        public Box2D(float sizeX, float sizeZ, float posX, float posZ)
        {
            this.sizeX = sizeX;

            this.sizeZ = sizeZ;

            this.posX = posX;

            this.posZ = posZ;

            this.offsetX = 0;

            this.offsetZ = 0;
        }


        public virtual void updateSize(float[] sizeLst)
        {
            updateSize(sizeLst[0], sizeLst[1]);
        }

        public virtual void updateSize(float sizeX, float sizeZ)
        {
            this.sizeX = sizeX;
            this.sizeZ = sizeZ;
        }

        public virtual void updateOffset(float[] offsetLst)
        {
            updateOffset(offsetLst[0], offsetLst[1]);
        }

        public virtual void updateOffset(float offsetX, float offsetZ)
        {
            this.offsetX = offsetX;
            this.offsetZ = offsetZ;
        }

        public float xMin
        {
            get
            {
                return posX - sizeX * 0.5f + offsetX;
            }
        }

        public float xMax
        {
            get
            {
                return posX + sizeX * 0.5f + offsetX;
            }
        }

        public float zMin
        {
            get
            {
                return posZ - sizeZ * 0.5f + offsetZ;
            }
        }

        public float zMax
        {
            get
            {
                return posZ + sizeZ * 0.5f + offsetZ;
            }
        }
    }

}
